//
//  MyDataCell.m
//  GuShiNews
//
//  Created by 丁一 on 2019/8/17.
//  Copyright © 2019 Jones. All rights reserved.
//

#import "MyDataCell.h"
#import "CenterModel.h"
#import "HiJonesClass.h"

@interface MyDataCell ()

@property (nonatomic, strong) UILabel     *Name;

@end

@implementation MyDataCell

+ (instancetype)cellForTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID = @"MyDataCell";
    MyDataCell  *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell){
        cell=[[MyDataCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        cell.backgroundColor=[UIColor whiteColor];
        tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        [cell setSelectionStyle:UITableViewCellSelectionStyleDefault];
        cell.textLabel.textColor=[UIColor grayColor];
        cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
        
        [cell.contentView addSubview:cell.Name];
        [cell.contentView addSubview:cell.Img];
    }
    
    return cell;
}

- (void)setModel:(CenterModel *)Model{
    if (_Model != Model) {
        _Model = Model;
    }
    [_Name setFont:[UIFont boldSystemFontOfSize:18]];
    _Name.frame=CGRectMake(95, 10, RECRWITCH-135, 35);
    [_Name setTextColor:[JonesClass stringTOColor:@"#222222"]];
    if ([_Model.Type intValue]<20) {
        self.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        self.textLabel.text=_Model.Tittle;
        if ([_Model.Tittle isEqualToString:@"昵称"]) {
            self.Name.text=_SuperModel.name;
        }else if ([_Model.Tittle isEqualToString:@"性别"]){
            if ([_SuperModel.sex isEqualToString:@"False"]) {
                self.Name.text=@"男";
            }else{
                self.Name.text=@"女";
            }
        }else if ([_Model.Tittle isEqualToString:@"年龄"]){
            self.Name.text=[NSString stringWithFormat:@" %li",(long)[HiJonesClass ageWithDateOfBirth:_SuperModel.briday]];
        }else if ([_Model.Tittle isEqualToString:@"星座"]){
            self.Name.text=[NSString stringWithFormat:@"%@座",[HuaHereClass getAstroWith:_SuperModel.briday]];
        }
    }
    if ([_Model.Type intValue]==0) {
        _Name.hidden = YES;
        _Img.hidden = NO;
        [_Img sd_setImageWithURL:[NSURL URLWithString:_SuperModel.logo] placeholderImage:[UIImage imageNamed:@"user_logo.png"]];
    }else{
        _Name.hidden = NO;
        _Img.hidden = YES;
    }
}

-(UILabel *)Name{
    if (!_Name) {
        _Name = [[UILabel alloc] initWithFrame:CGRectMake(95, 10, RECRWITCH-135, 35)];
        _Name.numberOfLines=0;
        _Name.textAlignment=NSTextAlignmentRight;
        [_Name setTextColor:[JonesClass stringTOColor:@"#222222"]];
    }
    return _Name;
}

-(UIImageView *)Img{
    if (!_Img) {
        _Img                     = [[UIImageView alloc] initWithFrame:CGRectMake(RECRWITCH-95, 15, 55, 55)];
        _Img.layer.masksToBounds = YES;
        _Img.contentMode = UIViewContentModeScaleAspectFill;
        _Img.layer.masksToBounds = YES;
        _Img.layer.cornerRadius = 27.5;
    }
    return _Img;
}

@end
